/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DataAccess;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Home
 */
public class ReceiptProduce {

    public static boolean insertReceiptProduce(ArrayList<Entity.BillSellDetails> billse, Entity.Bills b) {
        String sql = "insert into Receipt(BillID, accept) values(?, ?)";
        //String date = Entity.DateUtils.now("MM/dd/yy");
        //System.out.println(date);
        try {
            PreparedStatement pst = DBUtil.getConnection(DBUtil.getInfoDB()).prepareCall(sql);
            pst.setInt(1, b.getBillID());
            pst.setBoolean(2, false);
            
            int count = pst.executeUpdate();
            for (Entity.BillSellDetails billSellDetails : billse) {
                DataAccess.BillSellDetails.UpdateBillDetail(b, billSellDetails);
            }

//            for (Entity.BillSellDetails billSellDetails : billse) {
//                DataAccess.Item.updateItemQuantityReceipt(billSellDetails);
//            }
            if (count != 0) {
                return true;
            } else {
                return false;
            }
        } catch (SQLException ex) {
            Logger.getLogger(ReceiptProduce.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }
}
